package com.hailiang.study.javase.java.util;

import org.junit.Test;

import java.util.Arrays;

public class Arrays_copyOf {

    @Test
    public void test_copyOf_01() {
        String[] oldArr = new String[] {"hello", "world", "java"};
        String[] newArr = null;
        newArr = Arrays.copyOf(oldArr, 2);
        System.out.println(Arrays.toString(newArr)); // 输出：[hello, world]


        newArr = Arrays.copyOf(oldArr, oldArr.length);
        System.out.println(Arrays.toString(newArr)); // 输出：[hello, world, java]
    }

}
